package com.arceus.leetcode.dytedance;

/**
 * @author : iron
 * @version : 1.0.0
 * @date : 3:52 PM 2018/12/27
 */

public class T5 {

    public static void main(String[] args) {
        String s = "the sky is   blue";
        System.out.println(reverseWords(s));
    }

    public static String reverseWords(String s) {
        String[] s1 = s.split(" ");

        String res = "";
        for (int i = s1.length - 1; i >= 0; i--) {
            res += " " + s1[i];
           res =  res.trim();
        }
        return res;
    }
}
